package com.huiqiao.lesson6.beanLifeCallback;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//@Component
public class UserBean implements InitializingBean, DisposableBean {

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean ==> UserBean 已生成，可以在此做一些赋值等初始化操作");
    }

    @PostConstruct
    public void init() {
        System.out.println("@PostConstruct ==> UserBean 已生成，可以在此做一些赋值等初始化操作");
    }

    public void init2() {
        System.out.println("initMethod ==> UserBean 已生成，可以在此做一些赋值等初始化操作");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean ==> ioc关闭，正在销毁bean");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("@PreDestroy ==> ioc关闭，正在销毁bean");
    }

    public void destroy2() throws Exception {
        System.out.println("destroyMethod ==> ioc关闭，正在销毁bean");
    }
}
